<script setup lang="ts">
import { ref } from "vue";
const visible = ref<boolean>(false);
const hideDropdown = () => {
  visible.value = !visible.value;
};
</script>

<template>
  <div class="jy-header">
    <div class="jy-header-row">
      <div class="jy-header-logo flex">
        <div class="jy-logo">
          <img src="../assets/logo.png" alt="" />
        </div>
        <div class="jy-name">
          <span>jy-admin</span>
        </div>
      </div>

      <a-dropdown :trigger="['click']">
        <a class="ant-dropdown-link" @click.prevent>
          <div class="jy-header-user" @click="hideDropdown">
            <div class="jy-header-avatar">
              <div class="jy-avatar">
                <img src="../assets/avatar.jpg" alt="" />
              </div>
            </div>
            <div class="jy-header-user-name">
              <span>用户名称</span>
            </div>
          </div>
          <DownOutlined />
        </a>
        <template #overlay>
          <a-menu>
            <a-menu-item key="0">
              <a href="">个人中心</a>
            </a-menu-item>
            <a-menu-item key="1">
              <a href="">系统设置</a>
            </a-menu-item>
            <a-menu-divider />
            <a-menu-item key="3" style="color: red;">退出登录</a-menu-item>
          </a-menu>
        </template>
      </a-dropdown>
    </div>
  </div>
</template>

<style lang="less" scoped>
.jy-header {
  box-sizing: border-box;
  padding: 1rem 4rem 1rem 0rem;
  background-color: var(--body-background-);

  .jy-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;

    .jy-header-logo {
      align-content: center;
      height: var(--header-height-);
      font-weight: 700;
      font-size: var(--font-size-middle-);
      align-items: center;
      justify-content: center;

      @media screen and (min-width: 1200px) {
        width: 17.8571rem;
      }

      @media (max-width: 1199px) and (min-width: 992px) {
        width: 17.8571rem;
      }

      @media (max-width: 991px) and (min-width: 768px) {
        width: 8.9286rem;
      }

      @media (max-width: 767px) and (min-width: 480px) {}

      .jy-logo {
        display: flex;
        justify-content: center;
        align-content: center;
        flex-wrap: wrap-reverse;

        img {
          width: 2.5714rem;
          height: 2.5714rem;
        }
      }

      .jy-name {
        @media screen and (min-width: 1200px) {
          padding-left: 1rem;
        }

        @media (max-width: 1199px) and (min-width: 992px) {
          padding-left: 1rem;
        }

        @media (max-width: 991px) and (min-width: 768px) {
          display: none;
        }

        @media (max-width: 767px) and (min-width: 480px) {
          display: none;
        }
      }
    }

    .jy-header-user {
      display: flex;
      align-items: center;
      font-weight: 600;

      .jy-header-avatar {
        .jy-avatar {
          width: 2.6429rem;
          height: 2.6429rem;
          border-radius: 50%;
          overflow: hidden;
          cursor: pointer;

          img {
            max-width: 100%;
          }
        }
      }

      .jy-header-user-name {
        padding-left: 0.8571rem;
      }
    }
  }
}
</style>
